package com.test.demo.service.impl;

import com.test.demo.dao.UserMapper;
import com.test.demo.service.IUserService;
import com.test.demo.dean.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceimpl implements IUserService {

    @Autowired(required = false)
    private UserMapper userMapper;

    @Override
    public List<User> query(String name) {

        return userMapper.query(name);
    }

    @Override
    public void saveOrUpdate(User user) {
        if(user.getId() == null){
            userMapper.insert(user);
        } else {
            userMapper.update(user);
        }
    }



}
